package HJ;

import java.util.Scanner;

public class test1 {

    /**
     * 有一排停车位 1，0，0，0，0，1，0，0，1, 找到距离最近车辆的最大距离
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String str = in.nextLine();
            String[] strArray = str.split(",");
            int max = 0;
            for (int i = 0 ; i < strArray.length; i++) {
                if(strArray[i].equals("1")) {
                    continue;
                }
                int pre = 0;
                for (int x = i - 1; x >= 0; x-- ) {
                    pre++;
                    if (strArray[x].equals("1")) {
                        break;
                    }
                }
                int next = 0;
                for (int y = i + 1; y < strArray.length; y++ ) {
                    next++;
                    if (strArray[y].equals("1")) {
                        break;
                    }
                }
                // 位置不在首尾的话，要判断两边距离
                if (i != 0 && i !=  (strArray.length-1)) {
                    int reduceNum = next - pre;
                    if (reduceNum < 0) {
                        reduceNum = -reduceNum;
                    }
                    if (reduceNum > 1) {
                        continue;
                    }
                }
                if (i != 0 && i !=  (strArray.length-1)) {
                    pre = Math.min(pre, next);
                } else {
                    pre = Math.max(pre, next);
                }
                max = Math.max(pre, max);
            }
            System.out.println(max);
        }
    }
}
